import api from "@/api"
import { classifyitem } from "@/api/modules/classifiesff";
import { RoleItem } from "@/api/modules/roles";
// import { permissionData } from "process";
import { ref } from "vue";

export function useFetchData() {

    const classifyData = ref<classifyitem[]>([]);
    const permissionData = ref([]);
    const rolesData=ref<RoleItem[]>([]);
    // 获取所有分类数据
    const getClassifyDataAsync = async () => {
        const res = await api.classifies.search();
        if (res.code === 200) {
            classifyData.value = res.data.rows;
        }
    }

  //获取所有权限菜单数据哈哈
  const  getPermissionDataAsync = async () => {
    const res = await api.menus.search({
            creator:'huangyuling'
        });
        if (res.code==200) {
            permissionData.value = res.data.rows;
        }

    }

//获取所有角色数据

const  getRolesDataDataAsync = async () => {
    const res = await api.roles.search();
        if (res.code==200) {
            rolesData.value = res.data.rows;
        }

    }






        return {
            getClassifyDataAsync,
            classifyData,
            getPermissionDataAsync,
            permissionData,
            getRolesDataDataAsync,
            rolesData,
        }

}


